package com.google.code.jtasks.client.modules;

import com.google.code.jtasks.client.ui.Command;
import com.google.code.jtasks.client.ui.CommandDispatcher;
import com.google.code.jtasks.client.ui.commands.*;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.MapBinder;

/**
 * Модуль, отвечающий за настройку команд и их привязку к символам.
 */
public class CommandsModule extends AbstractModule {
    @Override
    protected void configure() {
        binder().requireExplicitBindings();

        MapBinder<Character, Command> commandBinder = MapBinder.newMapBinder(binder(), Character.class, Command.class);

        commandBinder.addBinding('1').to(ListTasksCommand.class);
        commandBinder.addBinding('2').to(NewTaskCommand.class);
        commandBinder.addBinding('3').to(FindTasksCommand.class);
        commandBinder.addBinding('4').to(DeleteTaskCommand.class);
        commandBinder.addBinding('c').to(ChangeServiceUriCommand.class);
        commandBinder.addBinding('q').to(QuitCommand.class);

        bind(DefaultCommand.class);

        bind(CommandDispatcher.class);
    }
}
